﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Windows.Forms;

namespace FAST
{
    /// <summary>
    /// A data structure that will be used throughout the structure. When it is being inherited by two subclasses, the FileHandler and the FolderHandler which will distinguish
    /// whether the files are belong to the FileHandler or FolderHandler.
    /// </summary>
    [Serializable()]
    public class FilesHandler : IEquatable<FilesHandler>
    {
        private bool fileType;

        /// <summary>
        /// An instance of FilesHandler object which can be reference to its sub-classes (FileHandler or FolderHandler).
        /// </summary>
        /// <exception cref="InvalidCastExpression">An attempt was made to cast to an invalid class.(FileHandler or FolderHandler)</exception>
        public FilesHandler()
        {
        }

        public void setTypeFile(bool type)
        {
            fileType = type;
        }

        /// <summary>
        /// Return bool to determine whether it is a FileHandler or FolderHandler.
        /// </summary>
        /// <returns>Return true or false.</returns>
        public bool isTypeFile()
        {
            return fileType;
        }

        public bool Equals(FilesHandler handler)
        {
            if (this.isTypeFile() == true && handler.isTypeFile() == true)
            {
                if (((FileHandler)this).getSubFilePath() == ((FileHandler)handler).getSubFilePath())
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }
            else if (this.isTypeFile() == false && handler.isTypeFile() == false)
            {
                if (((FolderHandler)this).getFullFolderPath() == ((FolderHandler)handler).getFullFolderPath())
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }
            else
            {
                return false;
            }

        }

    }
}
